<!DOCTYPE html>
<html>
<head>
    <title>安置协议打印</title>
<#include "../common/common.ftl"/>
</head>
<body>
<div class="layui-fluid">
    <blockquote class="layui-elem-quote layui-bg-white">
        安置协议签署：【姓名：<span class="jmdf-color-red">${(contract.name)!}</span>】【协议编号：<span
            class="jmdf-color-red">${(contract.contractCode)!}</span>】
    </blockquote>

    <div class="layui-row layui-col-space15">
        <div class="layui-col-lg5 layui-col-md5">
            <div class="layui-card">
                <div class="layui-card-header">
                    第一步：打印安置协议一
                </div>
                <div class="layui-card-body">
                    <button type="button" class="layui-btn layui-btn-fluid printBtn print"
                            source="/pdf/print/resetAgreementPrintPDF1?contractId=${(contract.id)!}">
                        <i class="layui-icon layui-icon-search"></i>预览安置协议一
                    </button>
                </div>
            </div>

            <div class="layui-card">
                <div class="layui-card-header">
                    第二步：打印安置协议二
                    <button type="button" class="layui-btn layui-btn-xs printBtn print"
                            source="/pdf/print/houseFpPrint?contractId=${(contract.id)!}">
                        <i class="layui-icon layui-icon-search"></i>预览安置房分配表
                    </button>
                    <button type="button" class="layui-btn layui-btn-xs setBuyHousePersonType">修改产权人信息</button>

                </div>
                <div class="layui-card-body">
                    <table class="layui-table">
                        <tr>
                            <th style="text-align: center;min-width: 100px">所在小区</th>
                            <th style="text-align: center;min-width: 80px">户号</th>
                            <th style="text-align: center;min-width: 100px">操作</th>
                        </tr>
                    <#if (houseList??)>
                        <#list houseList as house>
                            <tr>
                                <td style="text-align: center;">${house.azProject.projectName}</td>
                                <td style="text-align: center;">${house.houseNumStr}</td>
                                <td style="text-align: center;">
                                    <#if contract.azSignStatus != 2 >
                                        <button type="button" class="layui-btn layui-btn-xs chooseBuyHousePerson"
                                                houseId=${(house.id)!}>
                                            <i class="layui-icon layui-icon-edit"></i>变更产权人
                                        </button>
                                    </#if>
                                    <button type="button" class="layui-btn layui-btn-xs printBtn"
                                            source="/pdf/print/resetAgreementPrintPDF2?houseId=${(house.id)!}">
                                        <i class="layui-icon layui-icon-search"></i>预览协议
                                    </button>
                                </td>
                            </tr>
                        </#list>
                    </#if>
                    <#if (noHouseStorageRoomList??)>
                        <#list noHouseStorageRoomList as noHouseStorageRoom>
                            <tr>
                                <td style="text-align: center;">${noHouseStorageRoom.azProject.projectName}</td>
                                <td style="text-align: center;">${noHouseStorageRoom.houseNumStr}</td>
                                <td style="text-align: center;">
                                    <#if contract.azSignStatus != 2 >
                                        <button type="button" class="layui-btn layui-btn-xs chooseBuyStorageRoomPerson"
                                                storageRoomId=${(noHouseStorageRoom.id)!}>
                                            <i class="layui-icon layui-icon-edit"></i>变更产权人
                                        </button>
                                    </#if>
                                    <button type="button" class="layui-btn layui-btn-xs printBtn"
                                            source="/pdf/print/storageRoomPrintPDF?storageRoomId=${(noHouseStorageRoom.id)!}">
                                        <i class="layui-icon layui-icon-search"></i>预览协议
                                    </button>
                                </td>
                            </tr>
                        </#list>
                    </#if>
                    <#if (carLotList??)>
                        <#list carLotList as car>
                            <tr>
                                <td style="text-align: center;">${car.azProject.projectName}</td>
                                <td style="text-align: center;">${car.houseNumStr}</td>
                                <td style="text-align: center;">
                                    <#if contract.azSignStatus != 2 >
                                        <button type="button" class="layui-btn layui-btn-xs chooseBuyCarLotPerson"
                                                carLotId=${(car.id)!}>
                                            <i class="layui-icon layui-icon-edit"></i>变更产权人
                                        </button>
                                    </#if>
                                    <button type="button" class="layui-btn layui-btn-xs printBtn"
                                            source="/pdf/print/carLotPrintPDF?carId=${(car.id)!}">
                                        <i class="layui-icon layui-icon-search"></i>预览协议
                                    </button>
                                </td>
                            </tr>
                        </#list>
                    </#if>
                    </table>
                </div>
            </div>

            <div class="layui-card">
                <div class="layui-card-header">
                    第三步：设置签约状态：
                <#if contract.azSignStatus == 1><span class="jmdf-color-red">未签约</span></#if>
                <#if contract.azSignStatus == 2><span class="jmdf-color-green">已签约</span></#if>
                <#if contract.azSignStatus == 3><span class="jmdf-color-blue">数据退回</span></#if>
                </div>
                <div class="layui-card-body">
                    <button class="layui-btn layui-btn-fluid azSign
                    <#if contract.azSignStatus == 2>layui-btn-danger</#if>" contractId="${(contract.id)!}">
                    <#if contract.azSignStatus == 2>设置为数据退回<#else>设置为已签约</#if>
                    </button>
                </div>
            </div>
            <div class="layui-card">
                <div class="layui-card-header">
                    第四步：打印交房告知书
                </div>
                <div class="layui-card-body">
                    <button type="button" class="layui-btn layui-btn-fluid printBtn print"
                            source="/pdf/print/takeHouseGZPDF?contractId=${(contract.id)!}">
                        <i class="layui-icon layui-icon-search"></i>预览交房告知书
                    </button>
                </div>
            </div>
            <div class="layui-card">
                <div class="layui-card-header">
                    第五步：打印安置选房审批表
                    <button type="button" class="layui-btn layui-btn-xs setSpForm">修改审批表信息</button>
                </div>
                <div class="layui-card-body">
                    <button type="button" class="layui-btn layui-btn-fluid printBtn print"
                            source="/pdf/print/xfSpPrint?contractId=${(contract.id)!}">
                        <i class="layui-icon layui-icon-search"></i>预览安置选房审批表
                    </button>
                </div>
            </div>

            <#--<div class="layui-card">-->
                <#--<div class="layui-card-header">-->
                    <#--打印安置房继承、赠与具结保证书-->
                <#--</div>-->
                <#--<div class="layui-card-body">-->
                    <#--<button type="button" class="layui-btn layui-btn-fluid printBtn print"-->
                            <#--source="/pdf/print/houseInheritPDF?contractId=${(contract.id)!}">-->
                        <#--<i class="layui-icon layui-icon-search"></i>安置房继承具结保证书-->
                    <#--</button>-->
                <#--</div>-->
                <#--<div class="layui-card-body">-->
                    <#--<button type="button" class="layui-btn layui-btn-fluid printBtn print"-->
                            <#--source="/pdf/print/houseGiftPDF?contractId=${(contract.id)!}">-->
                        <#--<i class="layui-icon layui-icon-search"></i>安置房赠与具结保证书-->
                    <#--</button>-->
                <#--</div>-->
            <#--</div>-->
        </div>
        <div class="layui-col-lg7 layui-col-md7" style="height: 700px;">
            <iframe id="printIframe" style="width: 100%;height: 99%;"></iframe>
        </div>
    </div>
</div>
<script src="/layui/layui.js" charset="utf-8"></script>
<script>
    layui.config({
        base: '/modules/' //静态资源所在路径
    }).use(['form', 'jquery', 'jmdf', 'page'], function () {
        var $ = layui.jquery, jmdf = layui.jmdf;

//        打印链接调用
        function openPdf(source) {
            var url = source + "#toolbar=0";
            $("#printIframe").attr("src", url);
        }

        $(".printBtn").click(function () {
            var source = $(this).attr("source");
            openPdf(source);
        });

        openPdf($(".printBtn").attr("source"));

//        签约方法
        $(".azSign").click(function () {
            var azSignStatus = '${contract.azSignStatus}';
            var msg = '${contract.azSignStatus}' == 1 ? "已签约" : "未签约";

            layer.open({
                title: false, shade: 0.5, content: "确认设置为" + msg + "吗？", btn: ['确定', '取消'], closeBtn: 0, btnAlign: 'c'
                , yes: function (index) {
                    $.get("azSign", {contractId: '${(contract.id)!}', _time: new Date().getTime()}, function (data) {
                        if (data.code == "0001") {//成功
                            parent.loadData();
                            layer.msg(data.message, {anim: 0, icon: 1, time: 1000}, function () {
                                location.reload();
                            });
                        } else {//失败
                            layer.msg(data.message, {anim: 6, icon: 2, time: 3000});
                        }
                        layer.close(index);
                    });
                }
            });
        });
        $(".chooseBuyHousePerson").click(function () {
            var obj = $(this);
            var houseId = obj.attr("houseId");
            jmdf.view("chooseBuyPersonList?contractId=" + ${(contract.id)!} +"&houseId=" + houseId, "100");
        });

        $(".chooseBuyStorageRoomPerson").click(function () {
            var obj = $(this);
            var storageRoomId = obj.attr("storageRoomId");
            jmdf.view("chooseBuyPersonList?contractId=" + ${(contract.id)!} +"&storageRoomId=" + storageRoomId, "100");
        });

        $(".chooseBuyCarLotPerson").click(function () {
            var obj = $(this);
            var carLotId = obj.attr("carLotId");
            jmdf.view("chooseBuyPersonList?contractId=" + ${(contract.id)!} +"&carLotId=" + carLotId, "100");
        })

        //审批表基础信息页面
        $(".setSpForm").click(function () {
            jmdf.minForm("setSpForm?contractId=${(contract.id)!}","1000px", "600px");
        })
        //产权人基础信息页面
        $(".setBuyHousePersonType").click(function () {
            jmdf.minForm("setBuyHousePersonTypeForm?contractId=${(contract.id)!}","1000px", "600px");
        })
    })
</script>
</body>
</html>